home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cmouse.zip / GMICE.PAS < prev    next >
Pascal/Delphi Source File  |  1987-12-10  |  3KB  |  97 lines

  1. Program gmice;
  2.  
  3.    { Illustrates the four graphics mouse cursors from gmouscur.inc, }
  4.    {    plus the default graphics cursor.                           }
  5.  
  6. Uses mouse, graph;
  7.  
  8. {$i gmouscur.inc}
  9.  
  10. CONST  eventMask = $54;       { mask to trip event handler when any
  11.                                            mouse button is released }
  12.  
  13. VAR    theMouse     : resetRec;
  14.        driver, mode : INTEGER;
  15. { ----------------------------------------------------------------- }
  16.  
  17. PROCEDURE Identify (title : string);
  18.  
  19.     { Write name of cursor near top of screen }
  20.  
  21. VAR    x : INTEGER;
  22.  
  23. BEGIN
  24.   SetViewPort (0, 0, GetMaxX, 30, TRUE);
  25.   ClearViewPort;
  26.   SetTextStyle (DefaultFont, HorizDir, 1);
  27.   x := (GetMaxX - TextWidth (title)) DIV 2;
  28.   OutTextXY (x, 20, title);
  29.   SetViewPort (0, 0, GetMaxX, GetMaxY, TRUE);
  30. END;
  31. { --------------------------- }
  32.  
  33. PROCEDURE GraphicScreen (title : string);
  34.  
  35.     { Creates a graphics screen and shows the title }
  36.  
  37. VAR    x, y   : INTEGER;
  38.        prompt : string [30];
  39.  
  40. BEGIN
  41.   InitGraph (driver, mode, '\DRIVERS');         { set graphics mode }
  42.   IF GraphResult = grOk THEN BEGIN
  43.     Identify (title);
  44.     Prompt := 'Click any button to continue';
  45.     x := (GetMaxX - TextWidth (prompt)) DIV 2;    { start of prompt }
  46.     OutTextXY (x, GetMaxY - 20, prompt);
  47.  
  48.   { Prepare to draw a rectangle as a lighted backdrop for cursor }
  49.     SetFillStyle (SolidFill, 1);
  50.     SetColor (1);
  51.     x := (GetMaxX DIV 2) - 50;
  52.     y := (GetMaxY DIV 2) - 50;                        { set corners }
  53.     Rectangle (x, y, x+100, y+100);                          { draw }
  54.     FloodFill (GetMaxX DIV 2, GetMaxY DIV 2, 1);             { fill }
  55.   END;
  56. END;
  57. { --------------------------- }
  58.  
  59. PROCEDURE demo (cursor : gCursRec; title : STRING);
  60.  
  61.     { Show the indicated graphics cursor }
  62.  
  63. BEGIN
  64.   Identify (title);
  65.   mGraphCursor (cursor.hotX, cursor.hotY,
  66.                 seg (cursor.image^), ofs (cursor.image^));
  67.   theEvents.flag := 0;
  68.   REPEAT UNTIL theEvents.flag <> 0;
  69. END;
  70. { --------------------------- }
  71.  
  72. BEGIN
  73. { Set up for run }
  74.   Driver := CGA;
  75.   Mode :=   CGAhi;
  76.   InitGCurs;                         { initialize the cursor images }
  77.   mReset (theMouse);
  78.   IF theMouse.exists THEN BEGIN
  79.     mInstTask (eventMask, seg (EventHandler), ofs (EventHandler));
  80.  
  81. { Show default cursor }
  82.     GraphicScreen ('Default cursor');
  83.     mShow;
  84.     theEvents.flag := 0;
  85.     REPEAT UNTIL theEvents.flag <> 0;
  86.   END;
  87.  
  88. { Show the custom cursors }
  89.   Demo (check, 'Check cursor');
  90.   Demo (arrow, 'Left arrow cursor');
  91.   Demo (cross, 'Cross cursor');
  92.   Demo (hand,  'Pointing hand');
  93.   Demo (iBeam, 'I-Beam cursor');
  94.   mReset (theMouse);
  95.   CloseGraph;
  96. END.
  97.